//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES OR INDEMNITIES.
//
#ifndef __BOOT_NOTIFY_H
#define __BOOT_NOTIFY_H

#ifdef __cplusplus
extern "C" {
#endif

//------------------------------------------------------------------------------
//
//  Enum:  BOOT_NOTIFICATION_CODE
//
//  This enumeration is used to de-couple IPL code from user notification. It
//  encapsulates iteraction from IPL to user. An OEM can extend code as needed
//  by using values from BOOT_NOTIFY_OEM up.
//
enum BOOT_NOTIFY_ID {
    BOOT_NOTIFY_POWERON  = 0x00010001,
    BOOT_NOTIFY_RUN      = 0x00010002,
    BOOT_NOTIFY_CHARGING = 0x00010003,
    BOOT_NOTIFY_ERASE    = 0x00020001,
    BOOT_NOTIFY_ULDR     = 0x00020002,
    BOOT_NOTIFY_SLEEP    = 0x00030001,
    BOOT_NOTIFY_AWAKE    = 0x00030002,
    BOOT_NOTIFY_OEM      = 0x80000000
};

enum BOOT_NOTIFY_CHARGING_CODE {
    BOOT_NOTIFY_CHARGING_STOP = 0,
    BOOT_NOTIFY_CHARGING_START = 1,
    BOOT_NOTIFY_CHARGING_ACTIVE = 2,
    BOOT_NOTIFY_CHARGING_FULL = 3,
};

typedef struct BOOT_NOTIFY_CHARGING_PARAMS {
    UINT32 code;
    UINT32 percentage;
} BOOT_NOTIFY_CHARGING_PARAMS;

typedef struct BOOT_NOTIFY_ERASE_PARAMS {
    BOOL confirmed;
} BOOT_NOTIFY_ERASE_PARAMS;

typedef struct BOOT_NOTIFY_ULDR_PARAMS {
    BOOL confirmed;
} BOOT_NOTIFY_ULDR_PARAMS;

//------------------------------------------------------------------------------

VOID
OEMBootNotify(
    UINT32 code,
    VOID* pData,
    UINT32 dataSize
    );

//------------------------------------------------------------------------------

__inline
VOID
BootNotifyPowerOn(
    )
{
    OEMBootNotify(BOOT_NOTIFY_POWERON, NULL, 0);
}

//------------------------------------------------------------------------------

__inline
VOID
BootNotifyRun(
    )
{
    OEMBootNotify(BOOT_NOTIFY_RUN, NULL, 0);
}

//------------------------------------------------------------------------------

__inline
VOID
BootNotifyCharging(
    UINT32 code,
    UINT32 percentage
    )
{
    BOOT_NOTIFY_CHARGING_PARAMS params;

    params.code = code;
    params.percentage = percentage;
    OEMBootNotify(BOOT_NOTIFY_CHARGING, &params, sizeof(params));
}

//------------------------------------------------------------------------------

__inline
BOOL
BootNotifyConfirmErase(
    )
{
    BOOL confirmed;
    OEMBootNotify(BOOT_NOTIFY_ERASE, &confirmed, sizeof(confirmed));
    return confirmed;
}

//------------------------------------------------------------------------------

__inline
BOOL
BootNotifyConfirmUldr(
    )
{
    BOOL confirmed;
    OEMBootNotify(BOOT_NOTIFY_ULDR, &confirmed, sizeof(confirmed));
    return confirmed;
}

//------------------------------------------------------------------------------

#ifdef __cplusplus
}
#endif

#endif // __BOOT_NOTIFY_H